package com.ruoyi.doorBindQuery.service.impl;

import java.util.List;

import com.ruoyi.data.MD5;
import com.ruoyi.doorBindQuery.domain.HouseDoorBindQuery;
import com.ruoyi.doorBindQuery.mapper.HouseDoorBindQueryMapper;
import com.ruoyi.doorBindQuery.service.IHouseDoorBindQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 户绑定Service业务层处理
 *
 * @author lijie
 * @date 2025-04-17
 */
@Service
public class HouseDoorBindQueryServiceImpl implements IHouseDoorBindQueryService
{
    @Autowired
    private HouseDoorBindQueryMapper houseDoorBindQueryMapper;

    /**
     * 查询户绑定
     *
     * @param bindId 户绑定主键
     * @return 户绑定
     */
    @Override
    public HouseDoorBindQuery selectHouseDoorBindQueryByBindId(Long bindId)
    {
        return houseDoorBindQueryMapper.selectHouseDoorBindQueryByBindId(bindId);
    }

    @Override
    public HouseDoorBindQuery getBindInfo(String hotId)
    {
        return houseDoorBindQueryMapper.getBindInfo(hotId);
    }

    /**
     * 查询户绑定列表
     *
     * @param houseDoorBindQuery 户绑定
     * @return 户绑定
     */
    @Override
    public List<HouseDoorBindQuery> selectHouseDoorBindQueryList(HouseDoorBindQuery houseDoorBindQuery)
    {
        return houseDoorBindQueryMapper.selectHouseDoorBindQueryList(houseDoorBindQuery);
    }

    @Override
    public List<HouseDoorBindQuery> getAreaBindInfo(HouseDoorBindQuery houseDoorBindQuery)
    {
        return houseDoorBindQueryMapper.getAreaBindInfo(houseDoorBindQuery);
    }

    @Override
    public List<HouseDoorBindQuery> getGroupBindInfo(HouseDoorBindQuery houseDoorBindQuery)
    {
        return houseDoorBindQueryMapper.getGroupBindInfo(houseDoorBindQuery);
    }

    @Override
    public List<HouseDoorBindQuery> getUnitBindInfo(HouseDoorBindQuery houseDoorBindQuery)
    {
        return houseDoorBindQueryMapper.getUnitBindInfo(houseDoorBindQuery);
    }

    @Override
    public List<HouseDoorBindQuery> getDoorBindInfo(HouseDoorBindQuery houseDoorBindQuery)
    {
        return houseDoorBindQueryMapper.getDoorBindInfo(houseDoorBindQuery);
    }


    @Override
    public int insertHouseDoorBindQuery(HouseDoorBindQuery houseDoorBindQuery)
    {
        return houseDoorBindQueryMapper.insertHouseDoorBindQuery(houseDoorBindQuery);
    }

    @Override
    @Transactional
    public void importDoorBindInfo(List<HouseDoorBindQuery> userList) throws Exception {
        for (HouseDoorBindQuery houseDoorBindQuery : userList) {
            if(houseDoorBindQuery.getUserName()!=null){
                houseDoorBindQuery.setUserName(MD5.encrypt(houseDoorBindQuery.getUserName()));
            }
            if(houseDoorBindQuery.getTel()!=null){
                houseDoorBindQuery.setTel(MD5.encrypt(houseDoorBindQuery.getTel()));
            }
            houseDoorBindQueryMapper.insertHouseDoorBindQuery(houseDoorBindQuery);
        }

    }


    /**
     * 修改户绑定
     *
     * @param houseDoorBindQuery 户绑定
     * @return 结果
     */
    @Override
    public int updateHouseDoorBindQuery(HouseDoorBindQuery houseDoorBindQuery)
    {
        return houseDoorBindQueryMapper.updateHouseDoorBindQuery(houseDoorBindQuery);
    }

    /**
     * 批量删除户绑定
     *
     * @param bindIds 需要删除的户绑定主键
     * @return 结果
     */
    @Override
    public int deleteHouseDoorBindQueryByBindIds(Long[] bindIds)
    {
        return houseDoorBindQueryMapper.deleteHouseDoorBindQueryByBindIds(bindIds);
    }

    /**
     * 删除户绑定信息
     *
     * @param bindId 户绑定主键
     * @return 结果
     */
    @Override
    public int deleteHouseDoorBindQueryByBindId(Long bindId)
    {
        return houseDoorBindQueryMapper.deleteHouseDoorBindQueryByBindId(bindId);
    }
}
